<template>
  <div class="wechat-setting-page">
    <page-header-wrapper>
      <page-tab-list>
        <a-alert message="此配置用于自动识别营业执照和身份证" type="info" show-icon style="margin:24px 0" />
        <a-form-model ref="wechatForm" :model="form" :labelCol="{ span: 3 }" :wrapperCol="{ span: 12 }">
          <a-form-model-item label="appkey">
            <a-input v-model="form.app_key" type="text" />
          </a-form-model-item>
          <a-form-model-item label="app秘钥">
            <a-input v-model="form.app_secret" type="text" />
          </a-form-model-item>
          <a-form-model-item :wrapper-col="{ span: 12, offset: 2 }">
            <a-button :loading="btnLoading" type="primary" @click="submitForm"> 保存 </a-button>
          </a-form-model-item>
        </a-form-model>
      </page-tab-list>
    </page-header-wrapper>
  </div>
</template>
<script>
import { orcSub, ocrInfo } from '@/api/setting/ocrConfig'
import storage from 'store'
export default {
  name: 'SettingOcr',
  components: {},
  data() {
    return {
      form: {
        app_key: '',
        app_secret: '',
      },
      btnLoading: false,
    }
  },
  created() {
    this.getData()
  },
  methods: {
    async getData() {
      const res = await ocrInfo({ store_id: storage.get('storeId') })
      if (res.code == 0) {
        console.log(res)
        this.form = res.data
      }
    },
    async submitForm() {
      this.btnLoading = true
      const res = await orcSub({ store_id: storage.get('storeId'), content: this.form })
      this.btnLoading = false
    },
  },
}
</script>
<style lang="less" scoped>
.wechat-setting-page {
  .required::before {
    content: '*';
    color: red;
  }
  .input-class {
    width: 1100px;
    margin: 10px 8px 25px 0;
  }
  input {
    max-width: 600px;
  }
}
</style>
